<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>


<probiz:pageHeading entityName="${recommendedType.recommendTitle}"
	entityHeadingKey="recommendedTypeDetail.heading" />

<content tag="buttons">
<probiz:iconBtn btnType="save" onclick="return fnDoSave();" />
<probiz:iconBtn btnType="back"
	onclick="return fnDoCancelForm(this);" />
</content>
<probiz:showBindErrors bindPath="recommendedType.*" />

<form:form method="post" cssClass="mainForm" id="recommendedTypeForm"
	name="recommendedTypeForm" commandName="recommendedType"
	action="${ctxPath}/sales/recommendedType.html">
<div class="top clearfix">
	<ul class="tab">
		<li class="curr"><span><fmt:message key="recommendedTypeDetail.heading"/></span></li>
	</ul>
</div>
<div class="modify">	
	<table class="com_modi_table" cellSpacing=0 cellPadding=0	width="100%" border=0>
		<tr>
			<input type="hidden" name="recommendedTypeId"	id="recommendedTypeId"	value="${recommendedType.recommendedTypeId}" />
			<th class="label_width_1">
				<StoreAdmin:label key="recommendedType.recommendTitle" />
			</th>
			<td>
				<span><input type="text" id="recommendTitle" name="recommendTitle"	value="${recommendedType.recommendTitle}" class="inputtxt" style="width:350px;"/></span>
			</td>
		</tr>	
		<tr>
			<th>
				<label for="checkbox_status"><fmt:message key="status.active" /></label>:
			</th>
			<td>
				<input type="checkbox" name="checkbox_status"
					id="checkbox_status"
					onclick="ChangeValueOfStatus(this,'status')"
					<c:if test="${recommendedType.status == 1}">checked</c:if>
					<c:if test="${recommendedType.recommendedTypeId == null}">checked</c:if> />
	
				<c:choose>
					<c:when test="${recommendedType.recommendedTypeId == null}">
						<input type="hidden" name="status" id="status" value="1" />
					</c:when>
					<c:otherwise>
						<form:hidden path="status" />
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
		<tr>
			<th>
				<label for="checkbox_autoEval">
					<fmt:message key="recommendedType.autoEval" />:
				</label>
			</th>
			<td>		
				<c:choose>
					<c:when test="${recommendedType.autoEval != 2}">
						<input type="checkbox" name="checkbox_autoEval"
							id="checkbox_autoEval"
							onclick="ChangeValueOfAutoEval(this,'autoEval')"
							<c:if test="${recommendedType.autoEval == 1}">checked</c:if>
							<c:if test="${recommendedType.autoEval == null}">checked</c:if> />
					</c:when>
					<c:otherwise>
						<fmt:message key="recommendedType.autoEval.s2"/>
					</c:otherwise>
				</c:choose>
				<c:choose>
					<c:when test="${recommendedType.recommendedTypeId == null}">
						<input type="hidden" name="autoEval" id="autoEval" value="1" />
					</c:when>
					<c:otherwise>
						<form:hidden path="autoEval" />
					</c:otherwise>
				</c:choose>
				
			</td>
		</tr>
		<tr>
			<th>
				<StoreAdmin:label key="recommendedType.typeName" />
			</th>
			<td>
				<span><input type="text" id="typeName" name="typeName"	value="${recommendedType.typeName}" readonly="true"  style="width:150px;"/></span>
			</td>
		</tr>
		<tr>
			<th>
				<StoreAdmin:label key="recommendedType.ruleCode" />
			</th>
			<td>
				<fmt:message key="recommendedType.ruleCode${recommendedType.ruleCode}" />
			</td>
		</tr>
		<tr>
			<th>
				<StoreAdmin:label key="recommendedType.position" />
			</th>
			<td>
				<c:choose>
					<c:when test="${recommendedType.isApplyToProduct == 1 and recommendedType.isApplyToCategory == 0}">
						<fmt:message key="recommendedType.position.product"/>
					</c:when>
					<c:when test="${recommendedType.isApplyToProduct == 0 and recommendedType.isApplyToCategory == 1}">
						<fmt:message key="recommendedType.position.category"/>
					</c:when>
				</c:choose>
			</td>
		</tr>
	
	</table>
</div>	
			
</form:form>
<v:javascript formName="recommendedType" staticJavascript="false" />

<script type="text/javascript" defer="true">
$j(document).ready(function () {
	
});	

function ChangeValueOfStatus(checkbox,persistInput)
{
    if (checkbox.checked==true)
    {
      	$(persistInput).value = 1;
    }
    else
    {
      	$(persistInput).value = 0;
    }
}

function ChangeValueOfAutoEval(checkbox,persistInput)
{
    if (checkbox.checked==true)
    {
      	$(persistInput).value = 1;
    }
    else
    {
      	$(persistInput).value = 0;
    }
}

function validateAction(){
	 if(!validateRecommendedType()){
    	return false;
   	}
   	   
    return true;
}

function fnDoSave(){
	var confirmMsg = __FMT.common_message_confirmSaveThis+"?";
	if(validateAction()){
    	if (!confirmMsg || confirm(confirmMsg)) {
	    	document.recommendedTypeForm.action += "?doAction=save";
			document.recommendedTypeForm.submit();
	    }
    }
}
</script>